#include "VectorOperations.h"

Vector3f::Vector3f(){
    x = 0;
    y = 0;
    z = 0;
}
Vector3f::Vector3f(float _x, float _y){
    x = _x;
    y = _y;
    z = 0;
}
Vector3f::Vector3f(float _x, float _y, float _z)
{
    x = _x;
    y = _y;
    z = _z;
}

float Vector3f::length()
{
    return sqrt((x*x)+(y*y)+(z*z));
}
float Vector3f::normalize()
{
    float length = this->length();
    x = x/length;
    y = y/length;
    z = z/length;
    return length;
}

void Vector3f::set(float _x, float _y, float _z){
    x = _x;
    y = _y;
    z = _z;
}
void Vector3f::set(Vector3f &Vec){
    x = Vec.x;
    y = Vec.y;
    z = Vec.z;
}

Vector3f Vector3f::cross(const Vector3f &Vec){
    Vector3f crossVec;
    crossVec.x = y*Vec.z - z*Vec.y; 
    crossVec.y = z*Vec.x - x*Vec.z;
    crossVec.z = x*Vec.y - y*Vec.x;
    return crossVec;
}
float Vector3f::dot(const Vector3f &Vec){
    return (x*Vec.x+y*Vec.y+z*Vec.z);
}

float Vector3f::findAngleBetween(Vector3f &otherVec)
{
	return acos(this->dot(otherVec) / this->length() / otherVec.length());
}

// OPERATOR OVERLOAD

void Vector3f::operator=(const Vector3f &Vec){
    x = Vec.x;
    y = Vec.y;
    z = Vec.z;
}
void Vector3f::operator+=(const Vector3f &Vec){
    x += Vec.x;
    y += Vec.y;
    z += Vec.z;
}
void Vector3f::operator-=(const Vector3f &Vec){
    x -= Vec.x;
    y -= Vec.y;
    z -= Vec.z;
}
void Vector3f::operator*=(const float scalar){
    x *= scalar;
    y *= scalar;
    z *= scalar;
}

//Vector3f Vector3f::operator*(const Vector3f &vec)
//{
//	return Vector3f(x * vec->x, y * vec.y, z * vec.z);
//}

//Vector3f Vector3f::operator/(const Vector3f &vec)
//{
//	return Vector3f(x / vec.x, y / vec.y, z / vec.z);
//}

bool Vector3f::operator==(const Vector3f &Vec){
    if( x == Vec.x &&
        y == Vec.y &&
        z == Vec.z)
        return true;
    else
        return false;
}
bool Vector3f::operator!=(const Vector3f &Vec){
    if( x == Vec.x &&
        y == Vec.y &&
        z == Vec.z)
        return false;
    else
        return true;
}

Vector3f Vector3f::operator+(const Vector3f &Vec){
        return Vector3f(this->x + Vec.x, this->y + Vec.y, this->z + Vec.z);
}
Vector3f Vector3f::operator-(const Vector3f &Vec){
    return Vector3f(this->x - Vec.x, this->y - Vec.y, this->z - Vec.z);
}

Vector3f Vector3f::operator+(const float scalar){
    return Vector3f(this->x + scalar, this->y + scalar, this->z + scalar);
}
Vector3f Vector3f::operator-(const float scalar){
    return Vector3f(this->x - scalar, this->y - scalar, this->z - scalar);
}
Vector3f Vector3f::operator*(const float scalar){
    return Vector3f(this->x * scalar, this->y * scalar, this->z * scalar);
}
Vector3f Vector3f::operator/(const float scalar){
    return Vector3f(this->x / scalar, this->y / scalar, this->z / scalar);
}